Skip to content

[Gradle] Clean up DataflowRunner's Java distroless container image build tasks#34999

Closed
sjvanrossum wants to merge 3 commits intoapache:masterfrom
sjvanrossum:gradle-fix-missing-dep
Closed

[Gradle] Clean up DataflowRunner's Java distroless container image build tasks#34999
sjvanrossum wants to merge 3 commits intoapache:masterfrom
sjvanrossum:gradle-fix-missing-dep

Conversation

@sjvanrossum
Copy link
Contributor

@sjvanrossum sjvanrossum commented May 19, 2025

Parts of this build file appear to be duplicated and/or outdated.

The container image build script in this build file:

tasks.register('buildAndPushDistrolessContainerImage', Task.class) {
  // Only Java 17 and 21 are supported.
  // See https://github.com/GoogleContainerTools/distroless/tree/main/java#image-contents.
  def allowed = ["java17", "java21"]
  doLast {
    def javaVer = project.findProperty('testJavaVersion')
    if (!allowed.contains(javaVer)) {
      throw new GradleException("testJavaVersion must be one of ${allowed}, got: ${javaVer}")
    }
    if (!project.hasProperty('dockerTag')) {
      throw new GradleException("dockerTag is missing but required")
    }
    def repository = "us.gcr.io/apache-beam-testing/${System.getenv('USER')}"
    def tag = project.findProperty('dockerTag')
    def imageURL = "${repository}/beam_${javaVer}_sdk_distroless:${tag}"
    exec {
      executable 'docker'
      workingDir rootDir
      args = [
              'buildx',
              'build',
              '-t',
              imageURL,
              '-f',
              'sdks/java/container/Dockerfile-distroless',
              "--build-arg=BEAM_BASE=gcr.io/apache-beam-testing/beam-sdk/beam_${javaVer}_sdk",
              "--build-arg=DISTROLESS_BASE=gcr.io/distroless/${javaVer}-debian12",
              '.'
      ]
    }
    exec {
      executable 'docker'
      args = ['push', imageURL]
    }
  }
}

Compared to the build file in sdks/java/container/distroless:

docker {
    name containerImageName(
            name: "${base_name}_distroless",
            root: root,
            tag: tag)
    tags containerImageTags()
    dockerfile project.file("../Dockerfile")
    files "./build/"
    buildArgs([
            'BEAM_BASE': base,
            'DISTROLESS_BASE': "gcr.io/distroless/java${imageJavaVersion}-debian12"
    ])
    buildx project.useBuildx()
    platform(*project.containerPlatforms())
    load project.useBuildx() && !pushContainers
    push pushContainers
}

Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@sjvanrossum sjvanrossum changed the title Fix version gating for buildAndPushDistrolessContainerImage [Gradle] Fix version gating for buildAndPushDistrolessContainerImage May 19, 2025
@sjvanrossum sjvanrossum force-pushed the gradle-fix-missing-dep branch from 510d29d to dda4c02 Compare May 19, 2025 14:31
@github-actions
Copy link
Contributor

Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment assign set of reviewers

@sjvanrossum sjvanrossum marked this pull request as draft May 19, 2025 15:48
@sjvanrossum sjvanrossum force-pushed the gradle-fix-missing-dep branch from 9fac2e1 to 7555d60 Compare May 19, 2025 18:44
@sjvanrossum sjvanrossum changed the title [Gradle] Fix version gating for buildAndPushDistrolessContainerImage [Gradle] Clean up DataflowRunner's Java distroless container image build tasks May 20, 2025
@sjvanrossum
Copy link
Contributor Author

Run Java PreCommit

@github-actions
Copy link
Contributor

This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@beam.apache.org list. Thank you for your contributions.

@github-actions github-actions bot added the stale label Jul 21, 2025
@github-actions
Copy link
Contributor

This pull request has been closed due to lack of activity. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.

@github-actions github-actions bot closed this Jul 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant